package leetcode_601_700;

public class LeeCode_643 {
    public static void main(String[] args) {

    }
    private static double findMaxAverage(int[] nums, int k) {
        int n = nums.length;
        int[] sums = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            sums[i] = sums[i - 1] + nums[i - 1];
        }
        int l = 0, r = l + k - 1;
        double max = Integer.MIN_VALUE;
        while (r < n){
            max = Math.max(sums[r + 1] - sums[l], max);
            l++;
            r++;
        }
        return max / k;
    }
}
